Dynamic Factor-Tilted Portfolio with Macro Stress Testing
Overview
This project dynamically constructs a factor-tilted portfolio using the Fama–French 5 Factor model. The historical factor data is sourced directly from Kenneth French’s website via web scraping. The portfolio adjusts its weights based on the current market regime (determined via SPY’s volatility and moving averages) and undergoes stress testing based on various market scenarios.
Features:
- Factor Modeling: Uses the Fama-French 5 Factor model, which includes:
MKT (Market): The excess return of the market over the risk-free rate, representing systematic market risk
SMB (Small Minus Big): The return spread between small and large market capitalization stocks, capturing the size premium
HML (High Minus Low): The return spread between high and low book-to-market stocks, measuring the value premium
RMW (Robust Minus Weak): The return spread between stocks with robust vs. weak profitability
CMA (Conservative Minus Aggressive): The return spread between companies with conservative vs. aggressive investment strategies
Market Regime Analysis: Uses SPY’s rolling volatility, moving averages, and RSI to determine the current market environment.
Dynamic Factor Tilting: Adjusts portfolio weights based on the identified market regime.
- Advanced Risk Analysis: Calculates risk metrics including:
Monte Carlo VaR/CVaR: Estimates risk using Student’s t-distribution simulations to better capture fat-tailed market behavior. Value-at-Risk (VaR) represents the potential loss at a given confidence level (e.g., 95%), while Conditional VaR (CVaR) estimates the expected loss when exceeding VaR threshold, providing a more complete view of tail risk.
Traditional metrics: Volatility, Sharpe ratio, and maximum drawdown
Higher-moment statistics: Skewness (distribution asymmetry) and kurtosis (tail thickness)
- Sophisticated Stress Testing: Evaluates performance under various adverse scenarios with detailed modeling of:
Return impacts (multiplicative and additive effects)
Volatility scaling
Skewness adjustments
Tail behavior (kurtosis) modifications
Interactive Visualizations: Provides Plotly-based interactive charts for deeper analysis.
Automated Documentation: Builds a comprehensive site with Sphinx, including interactive elements.
GitHub Pages Deployment: Automatically updates the site on a weekly schedule.
Portfolio Performance
Factor Correlations
Understanding factor correlations is crucial for diversification and factor tilting:
Risk Profile Comparison
The radar chart below compares risk metrics across different stress scenarios:
Risk Metrics
The following interactive charts display the risk metrics computed for both the baseline portfolio and under different stress scenarios.